import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '铅封编号',
    align: 'center',
    dataIndex: 'id',
  },
  {
    title: '领取状态',
    align: 'center',
    dataIndex: 'claimStatus_dictText',
  },
  {
    title: '检定状态',
    align: 'center',
    dataIndex: 'verificationStatus_dictText',
  },
  {
    title: '领用时间',
    align: 'center',
    dataIndex: 'collectionTime',
  },
  {
    title: '领用人',
    align: 'center',
    dataIndex: 'collectionBy_dictText',
  },
  {
    title: '送检单位',
    align: 'center',
    dataIndex: 'inspectionUnit',
  },
  {
    title: '施封日期',
    align: 'center',
    dataIndex: 'sealingTime',
  },
  {
    title: '施封位置',
    align: 'center',
    dataIndex: 'position',
  },
  {
    title: '是否报废',
    align: 'center',
    dataIndex: 'scrapped_dictText',
  },
  {
    title: '是否报损',
    align: 'center',
    dataIndex: 'reportLoss_dictText',
  },
  {
    title: '报损报废时间',
    align: 'center',
    dataIndex: 'scrappedLossTime',
  },
  {
    title: '是否自动通过',
    align: 'center',
    dataIndex: 'autoPass_dictText',
  },
  {
    title: '设备id',
    align: 'center',
    dataIndex: 'deviceId',
  },
  {
    title: '检查日期',
    align: 'center',
    dataIndex: 'checkDate',
  },
  {
    title: '下次检查日期',
    align: 'center',
    dataIndex: 'nextCheckDate',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'id',
    component: 'Input',
  },
  {
    label: '状态',
    field: 'claimStatus',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'seal_lead_claim_status',
      placeholder: '状态',
      stringToNumber: true,
    },
  },
  {
    label: '检定状态',
    field: 'verificationStatus_dictText',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'seal_lead_verification_status',
      placeholder: '状态',
      stringToNumber: true,
    },
  },
  {
    label: '操作员',
    field: 'createBy',
    component: 'JSelectUser',
  },
  {
    label: '是否已施封',
    field: 'id',
    component: 'Select',
    componentProps: {
      options: [
        { value: '0', label: '已施封' },
        { value: '1', label: '未施封' },
      ],
      //下拉多选
      mode: 'multiple',
      //配置是否可搜索
      showSearch: true,
    },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '芯片编码',
    field: 'chipCode',
    component: 'Input',
  },
  {
    label: '加密秘钥',
    field: 'secretKey',
    component: 'Input',
  },
  {
    label: '领取状态',
    field: 'claimStatus',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'seal_lead_claim_status',
    },
  },
  {
    label: '检定状态',
    field: 'verificationStatus',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'seal_lead_verification_status',
    },
  },
  {
    label: '领用时间',
    field: 'collectionTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
  },
  {
    label: '领用人',
    field: 'collectionBy',
    component: 'Input',
  },
  {
    label: '送检单位',
    field: 'inspectionUnit',
    component: 'Input',
  },
  {
    label: '施封日期',
    field: 'sealingTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
  },
  {
    label: '是否报废',
    field: 'scrapped',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'yn',
    },
  },
  {
    label: '是否报损',
    field: 'reportLoss',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'yn',
    },
  },
  {
    label: '报损报废时间',
    field: 'scrappedLossTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
  },
  {
    label: '是否自动通过',
    field: 'autoPass',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'yn',
    },
  },
  {
    label: '设备id',
    field: 'deviceId',
    component: 'Input',
  },
  {
    label: '检查日期',
    field: 'checkDate',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
  },
  {
    label: '下次检查日期',
    field: 'nextCheckDate',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
  },
  {
    label: '箱关系id',
    field: 'sealBoxId',
    component: 'Input',
  },
  {
    label: '盒关系id',
    field: 'sealBoxSmallId',
    component: 'Input',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  chipCode: { title: '芯片编码', order: 0, view: 'text', type: 'string' },
  secretKey: { title: '加密秘钥', order: 1, view: 'text', type: 'string' },
  claimStatus: { title: '领取状态', order: 2, view: 'list', type: 'string', dictCode: 'seal_lead_claim_status' },
  verificationStatus: { title: '检定状态', order: 3, view: 'list', type: 'string', dictCode: 'seal_lead_verification_status' },
  collectionTime: { title: '领用时间', order: 4, view: 'datetime', type: 'string' },
  collectionBy: { title: '领用人', order: 5, view: 'text', type: 'string' },
  inspectionUnit: { title: '送检单位', order: 6, view: 'text', type: 'string' },
  sealingTime: { title: '施封日期', order: 7, view: 'datetime', type: 'string' },
  scrapped: { title: '是否报废', order: 8, view: 'number', type: 'number', dictCode: 'yn' },
  reportLoss: { title: '是否报损', order: 9, view: 'number', type: 'number', dictCode: 'yn' },
  scrappedLossTime: { title: '报损报废时间', order: 10, view: 'datetime', type: 'string' },
  autoPass: { title: '是否自动通过', order: 11, view: 'list', type: 'string', dictCode: 'yn' },
  deviceId: { title: '设备id', order: 12, view: 'text', type: 'string' },
  checkDate: { title: '检查日期', order: 13, view: 'datetime', type: 'string' },
  nextCheckDate: { title: '下次检查日期', order: 14, view: 'datetime', type: 'string' },
  sealBoxId: { title: '箱关系id', order: 15, view: 'text', type: 'string' },
  sealBoxSmallId: { title: '盒关系id', order: 16, view: 'text', type: 'string' },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
